package com.example.shop_car_2208

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.view.isVisible
import com.example.shop_car_2208.databinding.ActivityWebView2Binding
import com.example.shop_car_2208.mvvm.BaseViewActivity

class WebViewActivity2 : BaseViewActivity<ActivityWebView2Binding>() {
    override fun initData() {

    }

    override fun initView() {
        val url = intent.getStringExtra("url").toString()
        binding.web.loadUrl(url)
        binding.web.webViewClient = WebViewClient()
        binding.web.settings.javaScriptEnabled =true
        val web1 = object: WebChromeClient(){
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if (newProgress == 100){
                    binding.pd.isVisible = false
                }
                binding.pd.progress = newProgress
            }
        }
        binding.web.webChromeClient = web1
    }

    override fun getLayout(): Int {
        return R.layout.activity_web_view2
    }

}